//
//  ANPriceView.m
//  Ants
//
//  Created by ZHM on 16/6/22.
//  Copyright © 2016年 ZHM. All rights reserved.
//

#import "ANPriceView.h"

@interface ANPriceView ()

@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *originPriceLabel;

@end

@implementation ANPriceView

- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.textColor = [UIColor orangeColor];
        _priceLabel.font = ANpriceLabelSize;
    }
    return _priceLabel;
}
- (UILabel *)originPriceLabel {
    if (!_originPriceLabel) {
        _originPriceLabel = [[UILabel alloc] init];
        _originPriceLabel.textColor = [UIColor lightGrayColor];
        _originPriceLabel.font = ANoriginPriceLabelSize;
    }
    return _originPriceLabel;
}
- (void)setPrice:(NSString *)price {
    self.priceLabel.text = price;
    [self addSubview:_priceLabel];
}
- (void)setOriginPrice:(NSString *)originPrice {
    self.originPriceLabel.text = originPrice;
    NSAttributedString *theAttributedString;
    theAttributedString = [[NSAttributedString alloc] initWithString:originPrice attributes:@{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],NSFontAttributeName: ANoriginPriceLabelSize}];
    _originPriceLabel.attributedText = theAttributedString;
    [self addSubview:_originPriceLabel];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    ANLog(@"%@",self.originPriceLabel.text);
    CGSize originPriceLabellSize = [self.originPriceLabel.text sizeOfTextWithMaxSize:CGSizeMake(self.width * 0.4, MAXFLOAT) font:ANoriginPriceLabelSize];
    _originPriceLabel.frame = (CGRect){{self.width - originPriceLabellSize.width ,self.height - originPriceLabellSize.height - 12},originPriceLabellSize};
    
    CGSize priceLabelSize = [self.priceLabel.text sizeOfTextWithMaxSize:CGSizeMake(self.width * 0.6, MAXFLOAT) font:ANpriceLabelSize];
    _priceLabel.frame = (CGRect){{self.width - originPriceLabellSize.width - priceLabelSize.width - 10,(self.height - priceLabelSize.height)/2},priceLabelSize};
    //_priceLabel.frame = CGRectMake(0, 0, self.frame.size.width/2, self.frame.size.height);
    
    //_originPriceLabel.frame = CGRectMake(self.frame.size.width/2, 2, self.frame.size.width/2, self.frame.size.height);
}


@end
